<template>
	<view class="beijingse">
		<view class="mainpadding">
			<view class="flexbetween ssbox" style="background-color: #fff;">
				<view class="flexleft">
					<u-icon name="search" color="#999" size="20"></u-icon>
					<input type="text" placeholder="请输入搜索内容" class="hei_text main_size bold" v-model="keywords" confirm-type="search" @confirm="shangjialb(keywords)">
				</view>
				<view class="rightss" @click="shangjialb(keywords)">搜索</view>
			</view>
		</view>
		<view class="mainpadding" style="padding-bottom: 180rpx;">
			<!-- 轮播图 -->
			<view class="">
				<u-swiper :list="list1" keyName="image_text" indicator circular @click="lbtclick($event,list1)"></u-swiper>
			</view>
			<view class="margin_top">
				<u-notice-bar :text="text1" direction="column" @click="enternews($event)"></u-notice-bar>
			</view>
			<!-- 分类 -->
			<!-- <view class="flexbetween mainpadding_top">
				<view class="lpbox " @click="tzgywm(1)">
					<view class="xiaohong titletext fonweight">会员大礼包</view>
					<view class="strongtext margin_top2" style="color: #FF9A7D;">好物相送</view>
				</view>
				<view class="ylbox "@click="tzgywm(3)">
					<view class=" titletext fonweight" style="color:#48BD93;">积分商城</view>
					<view class="strongtext margin_top2" style="color: #91DDC2;">好物相送</view>
				</view>
				<view class="flexcolumn" @click="tzgywm(4)">
					<image src="@/static/image/system/home2.png" style="width: 100rpx;height: 100rpx;" mode=""></image>
					<view class="xiaohei ershiba margin_top1 fonweight">非常2+1</view>
				</view>
				<view class="flexcolumn" @click="tzgywm(1)">
					<image src="@/static/image/system/home1.png" style="width: 100rpx;height: 100rpx;" mode=""></image>
					<view class="xiaohei ershiba margin_top1 fonweight">会员大礼包</view>
				</view>
				<view class="flexcolumn" @click="tzgywm(3)">
					<image src="@/static/image/system/home3.png" style="width: 100rpx;height: 100rpx;" mode=""></image>
					<view class="xiaohei ershiba margin_top1 fonweight">积分商城</view>
				</view>
			</view> -->
			<!--  商品推荐-->
			<view class="margin_top">
				<view class="flexbetween">
					<view class="flexleft">
						<view class="ggline margin_right2"></view>
						<view class=" titletext fonweight zhonghei">商品推荐</view>
					</view>
				</view>
				<goodslist :list="list.data"></goodslist>
			</view>
			
		</view>
		<view class="addBox" @click="goUrl">
			<image src="/static/image/system/add.png" mode="" style="width: 80rpx;height: 80rpx;"></image>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				list1: [],
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				text1: [],
				newsData: [],
				userInfo:{},
				keywords:"",
			}
		},
		onShareAppMessage: function(options) {
			return {
				title: '宜品佳商城',
				imageUrl: '',
				path: '/pages/homepage?otherinvite_code='+uni.getStorageSync("invite_code") || ""
			}
		},
		onShareTimeline: function() {
			return {
				title: '宜品佳商城',
				imageUrl: '',
				path: '/pages/homepage?otherinvite_code='+uni.getStorageSync("invite_code") || ""
			}
		},
		onLoad(options) {
			if(options.otherinvite_code){
				uni.setStorageSync("otherinvite_code",options.otherinvite_code)
			}
			this.getbanner()
			this.init()
			this.getnews()
		},
		methods: {
			goUrl(){
				uni.navigateTo({
					url:'/pages_mypage/myOrder'
				})
			},
			getnews() { //滚动消息
				httpRequest.request('/api/index/noticeIndex', 'GET', {
					page:1,
					type:2,
					limit:12
				}, false, false, true).then(res => {
					let arr = []
					res.data.data.forEach(item => {
						arr.push(item.name)
					})
					this.text1 = arr
					this.newsData = res.data.data
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			enternews(index) {
				uni.navigateTo({
					url: "/pages_homepage/gonggaoxq?id=" + this.newsData[index].id
				})
			},
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/goodscl/goodsList', 'GET', {
					page: page || 1,
					limit: _this.limit,
					type:2
				}).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			getbanner() { //获取轮播图
				httpRequest.request('/api/index/getAdvertiseList', 'POST', {
					advertise_position_id: 1,
					is_more: 1
				}).then(res => {
					this.list1 = res.data
				}).catch(err => {})
			},
			// 跳转礼品兑换以及医疗兑换
			tzgywm(i) {
				uni.navigateTo({
					url: '/pages_homepage/lipinlb?id=' + i
				})
			},
			shangjialb(){
				uni.navigateTo({
					url: '/pages_homepage/lipinlb?id=0&keywords='+this.keywords
				})
			},
			jumper(url) {
				uni.navigateTo({
					url: url
				})
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	.ylbox{
		width: 48.5%;
		padding: 44rpx 30rpx 28rpx 20rpx;
		background-size: 100% 100%;
		background-image: url('../static/image/system/yldh.png');
	}
	.lpbox{
		width: 48.5%;
		padding: 44rpx 30rpx 28rpx 20rpx;
		background-size: 100% 100%;
		background-image: url('../static/image/system/lpdh.png');
	}
	// 商品
	.sptp {
		width: 198rpx;
		height: 198rpx;
		border-radius: 11rpx 11rpx 11rpx 11rpx;
	}

	//结束
	.boxbai {
		padding: 16rpx;
		border-radius: 11rpx;
	}

	.ggline {
		width: 8rpx;
		height: 33rpx;
		border-radius: 23rpx;
		background-color: #FF9341;
	}

	.line {
		width: 2rpx;
		height: 17rpx;
		background: rgba(255, 147, 65, .6);
		border-radius: 1rpx 1rpx 1rpx 1rpx;
	}

	.gongg {
		width: 67rpx;
		height: 47rpx;
	}

	.huangbox {
		padding: 15rpx 20rpx;
		background: rgba(255, 147, 65, .1);
		border-radius: 8rpx 8rpx 8rpx 8rpx;
	}

	.dingbu {
		padding: 12rpx 30rpx 30rpx;
		background-size: 100% 100%;
		width: 100%;
		box-sizing: border-box;
		background-image: url('https://moveadd.yuntaiqi.com/uploads/20240105/19703999d12abe52e32e91e815d1c76b.png');
	}
	.spbox {
		width: 48%;
	}
	
	.sptp {
		width: 338rpx;
		height: 338rpx;
		border-radius: 11rpx 11rpx 0 0;
	}
	
	.spbox {
		background: #FFFFFF;
		border-radius: 11rpx 11rpx 11rpx 11rpx;
	}
	.addBox{
		position: fixed;
		bottom: 400rpx;
		right: 20rpx;
		width: 80rpx;
		height: 80rpx;
	}
</style>